home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 411_01 / vim / macros / hanoi / hanoi.mac < prev    next >
Encoding:
Text File  |  1993-12-13  |  1.1 KB  |  65 lines

  1. set remap
  2. set noterse
  3. set wrapscan
  4. " to set the height of the tower, change the digit in the following
  5. " two lines to the height you want (select from 1 to 9)
  6. map t 7
  7. map! t 7
  8. map L 1G/t
  9. X/^0
  10. $P1GJ$An$BGC0e$X0E0F$X/T
  11. @f
  12. @h
  13. $A1GJ@f0l$Xn$PU
  14. map g IL
  15.  
  16. map J /^0[^t]*$
  17.  
  18. map X x
  19. map P p
  20. map U L
  21. map A "fyl
  22. map B "hyl
  23. map C "fp
  24. map e "fy2l
  25. map E "hp
  26. map F "hy2l
  27.  
  28. " initialisations:
  29. " KM    cleanup buffer
  30. " Y    create tower of desired height
  31. " NOQ    copy it and inster a T
  32. " NO    copy this one
  33. " S    change last char into a $
  34. " R    change last char in previous line into a n
  35. " T    insert two lines containing a zero
  36. " V    add a last line containing a backslash
  37. map I KMYNOQNOSkRTV
  38.  
  39. "create empty line
  40. map K 1Go
  41.  
  42. "delete to end of file
  43. map M dG
  44.  
  45. "yank one line
  46. map N yy
  47.  
  48. "put
  49. map O p
  50.  
  51. "delete more than height-of-tower characters
  52. map q tllD
  53.  
  54. "create a tower of desired height
  55. map Y o0123456789Zq
  56.  
  57. "insert a T in column 1
  58. map Q 0iT
  59.  
  60. "substitute last character with a n
  61. map R $rn
  62.  
  63. "substitute last character with a $
  64. map S $r$
  65.  
  66. "insert two lines containing a zero
  67. map T ko0
  68. 0
  69.  
  70.  
  71. "add a backslash at the end
  72. map V Go/
  73.